<?php

use Phinx\Db\Adapter\MysqlAdapter;
use think\migration\Migrator;

class JoyshopVersion100 extends Migrator
{
    public function change(): void
    {
        $this->shop_advert_banner();
        $this->shop_advert_notice_bar();
        $this->shop_advert_hot_recommend();
        $this->shop_coupon();
        $this->shop_coupon_center();
        $this->shop_delivery_address();
        $this->shop_delivery_company();
        $this->shop_delivery_template();
        $this->shop_delivery_template_detail();
        $this->shop_goods();
        $this->shop_goods_classify();
        $this->shop_goods_params_template();
        $this->shop_goods_service();
        $this->shop_goods_sku();
        $this->shop_goods_spec_template();
        $this->shop_order();
        $this->shop_order_detail();
        $this->shop_order_address();
        $this->shop_order_delivery();
        $this->shop_order_delivery_detail();
        $this->shop_order_evaluate();
        $this->shop_order_export();
        $this->shop_order_crontab();
        $this->shop_order_refund();
        $this->shop_order_status_log();
        $this->shop_payment_trade();
        $this->shop_recharge_plan();
        $this->shop_recharge_order();
        $this->shop_setting();
        $this->shop_user();
        $this->shop_user_address();
        $this->shop_user_cart();
        $this->shop_user_coupon();
        $this->shop_user_favorite();
        $this->shop_user_money_log();
    }

    public function shop_advert_banner(): void
    {
        if (!$this->hasTable('shop_advert_banner')) {
            $table = $this->table('shop_advert_banner', [
                'id'          => false,
                'comment'     => '轮播图表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('goods_id', 'integer', ['comment' => '跳转商品ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('image', 'string', ['comment' => '轮播图', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('status', 'integer', ['comment' => '轮播图状态:0=禁用,1=启用', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('jump', 'integer', ['comment' => '是否跳转:0=否,1=是', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['status'], ['type' => 'BTREE'])
                ->addIndex(['jump', 'goods_id'], ['type' => 'BTREE'])
                ->create();
        }
    }

    public function shop_advert_notice_bar(): void
    {
        if (!$this->hasTable('shop_advert_notice_bar')) {
            $table = $this->table('shop_advert_notice_bar', [
                'id'          => false,
                'comment'     => '公告栏表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('title', 'string', ['comment' => '公告标题', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('content', 'text', ['comment' => '公告内容'])
                ->addColumn('status', 'integer', ['comment' => '状态:0=禁用,1=启用', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['status'], ['type' => 'BTREE'])
                ->create();
        }
    }

    public function shop_advert_hot_recommend(): void
    {
        if (!$this->hasTable('shop_advert_hot_recommend')) {
            $table = $this->table('shop_advert_hot_recommend', [
                'id'          => false,
                'comment'     => '热卖推荐表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('title', 'string', ['comment' => '标题', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('sub_title', 'string', ['comment' => '副标题', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('tags', 'string', ['comment' => '标签', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('image', 'string', ['comment' => '推荐图', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('status', 'integer', ['comment' => '状态:0=禁用,1=启用', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('classify_id', 'string', ['comment' => '跳转分类ID', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('goods_id', 'integer', ['comment' => '跳转商品ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['status'], ['type' => 'BTREE'])
                ->create();
        }
    }

    public function shop_coupon(): void
    {
        if (!$this->hasTable('shop_coupon')) {
            $table = $this->table('shop_coupon', [
                'id'          => false,
                'comment'     => '优惠券表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false,])
                ->addColumn('name', 'string', ['comment' => '优惠券名称', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('discount_type', 'integer', ['comment' => '优惠券类型:1=满减券,2=折扣券', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => 1])
                ->addColumn('discount_amount', 'decimal', ['comment' => '满减金额', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('discount_ratio', 'decimal', ['comment' => '折扣比例', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('min_price', 'decimal', ['comment' => '最低用券金额', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('range_type', 'integer', ['comment' => '适用范围:1=全部商品,2=部分商品', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => 1])
                ->addColumn('range_goods_ids', 'text', ['comment' => '适用范围商品ID集合'])
                ->addColumn('desc', 'string', ['comment' => '优惠券使用规则', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('status', 'integer', ['comment' => '状态:0=停用,1=正常', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => 1])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('update_time', 'biginteger', ['comment' => '修改时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addIndex(['discount_type'])
                ->addIndex(['discount_amount', 'min_price'], ['name' => 'idx_discount_amount'])
                ->addIndex(['discount_ratio', 'min_price'], ['name' => 'idx_discount_ratio'])
                ->addIndex(['status', 'delete_time'], ['name' => 'soft_delete'])
                ->create();
        }
    }

    public function shop_coupon_center(): void
    {
        if (!$this->hasTable('shop_coupon_center')) {
            $table = $this->table('shop_coupon_center', [
                'id'          => false,
                'comment'     => '领券中心记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false,])
                ->addColumn('coupon_id', 'string', ['comment' => '优惠券ID', 'null' => false, 'default' => '0'])
                ->addColumn('total_num', 'integer', ['comment' => '发放数量', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('remain_num', 'integer', ['comment' => '剩余数量', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('limit_num', 'integer', ['comment' => '限领数量', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('start_time', 'biginteger', ['comment' => '优惠券开始时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('end_time', 'biginteger', ['comment' => '优惠券结束时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('expiry_type', 'integer', ['comment' => '有效时间类型:1=固定时间,2=固定天数', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => 1])
                ->addColumn('active_start_time', 'biginteger', ['comment' => '活动开始时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('active_end_time', 'biginteger', ['comment' => '活动结束时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('expiry_days', 'integer', ['comment' => '领取后生效-有效天数', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('update_time', 'biginteger', ['comment' => '修改时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addIndex(['coupon_id'])
                ->addIndex(['expiry_type'])
                ->addIndex(['expiry_days'])
                ->addIndex(['start_time', 'end_time'], ['name' => 'expiry_time'])
                ->addIndex(['active_start_time', 'active_end_time'], ['name' => 'active_time'])
                ->create();
        }
    }

    public function shop_delivery_address(): void
    {
        if (!$this->hasTable('shop_delivery_address')) {
            $table = $this->table('shop_delivery_address', [
                'id'          => false,
                'comment'     => '物流地址表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '联系人', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('phone', 'string', ['comment' => '联系方式', 'limit' => 50, 'null' => false, 'default' => ''])
                ->addColumn('city', 'string', ['comment' => '地区选择ID集合', 'limit' => 50, 'null' => false, 'default' => ''])
                ->addColumn('address_detail', 'string', ['comment' => '详细地址', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('full_address', 'string', ['comment' => '完整地址', 'limit' => 300, 'null' => false, 'default' => ''])
                ->addColumn('type', 'integer', ['comment' => '地址类型:1=退货地址', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['city'])
                ->addIndex(['type'])
                ->create();
        }
    }

    public function shop_delivery_company(): void
    {
        if (!$this->hasTable('shop_delivery_company')) {
            $table = $this->table('shop_delivery_company', [
                'id'          => false,
                'comment'     => '物流公司表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '物流公司名称', 'limit' => 50, 'null' => false, 'default' => ''])
                ->addColumn('code_kd100', 'string', ['comment' => '物流公司编码(快递100)', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('code_kdniao', 'string', ['comment' => '物流公司编码(快递鸟)', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('status', 'integer', ['comment' => '状态:0=禁用,1=启用', 'limit' => MysqlAdapter::INT_TINY, 'default' => '1', 'null' => false])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex('status')
                ->create();
        }
    }

    public function shop_delivery_template(): void
    {
        if (!$this->hasTable('shop_delivery_template')) {
            $table = $this->table('shop_delivery_template', [
                'id'          => false,
                'comment'     => '运费模板表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '模板名称', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('type', 'integer', ['comment' => '计费方式:1=按件数,2=按重量,3=按体积', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->create();
        }
    }

    public function shop_delivery_template_detail(): void
    {
        if (!$this->hasTable('shop_delivery_template_detail')) {
            $table = $this->table('shop_delivery_template_detail', [
                'id'          => false,
                'comment'     => '运费模板详情',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('template_id', 'integer', ['comment' => '模板ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('template_group', 'string', ['comment' => '模板分组ID', 'limit' => 20, 'null' => false, 'default' => ''])
                ->addColumn('area_id', 'text', ['comment' => '选择的省份-城市ID集合'])
                ->addColumn('city_id', 'text', ['comment' => '城市ID集合'])
                ->addColumn('first', 'integer', ['comment' => '首件/首重', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('first_price', 'decimal', ['comment' => '首件/首重的价格', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('continue', 'integer', ['comment' => '续件/续重', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('continue_price', 'decimal', ['comment' => '续件/续重的价格', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['template_id'])
                ->create();
        }
    }

    public function shop_goods(): void
    {
        if (!$this->hasTable('shop_goods')) {
            $table = $this->table('shop_goods', [
                'id'          => false,
                'comment'     => '商品表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '商品名称', 'null' => false, 'default' => ''])
                ->addColumn('classify_id', 'text', ['comment' => '模板分组ID'])
                ->addColumn('images', 'text', ['comment' => '商品图片'])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('desc', 'string', ['comment' => '商品描述', 'null' => false, 'default' => ''])
                ->addColumn('status', 'integer', ['comment' => '状态:0=已下架,1=上线中', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('spec_list', 'text', ['comment' => '商品规格'])
                ->addColumn('min_price', 'decimal', ['comment' => 'SKU中最低价格', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('max_price', 'decimal', ['comment' => 'SKU中最高价格', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('min_origin_price', 'decimal', ['comment' => 'SKU中最低划线价', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('max_origin_price', 'decimal', ['comment' => 'SKU中最高划线价', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('total_stock', 'integer', ['comment' => 'SKU总库存', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('deduct_stock_type', 'integer', ['comment' => '库存扣减方式:1=下单减库存,2=付款减库存', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('stock_alert', 'integer', ['comment' => '库存预警值', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('sales_init', 'integer', ['comment' => '初始销量', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('sales_real', 'integer', ['comment' => '实际销量(SKU总和)', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delivery_type', 'integer', ['comment' => '运费类型:1=固定运费,2=运费模板', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('freight', 'decimal', ['comment' => '固定运费', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delivery_template_id', 'integer', ['comment' => '运费模板ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('params', 'text', ['comment' => '详情参数'])
                ->addColumn('detail_images', 'text', ['comment' => '详情图片'])
                ->addColumn('service_id', 'string', ['comment' => '服务与承诺ID', 'null' => false, 'default' => ''])
                ->addColumn('visit', 'integer', ['comment' => '访问量', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['name'])
                ->addIndex(['status', 'delete_time'], ['name' => 'soft_del'])
                ->create();
        }
    }

    public function shop_goods_classify(): void
    {
        if (!$this->hasTable('shop_goods_classify')) {
            $table = $this->table('shop_goods_classify', [
                'id'          => false,
                'comment'     => '商品分类表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '分类名称', 'null' => false, 'default' => ''])
                ->addColumn('pid', 'integer', ['comment' => '上级分类ID,顶级分类ID为0', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('icon', 'string', ['comment' => '分类图标', 'null' => false, 'default' => ''])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('status', 'integer', ['comment' => '状态:0=禁用,1=启用', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['name'], ['type' => 'UNIQUE'])
                ->addIndex(['pid'])
                ->addIndex(['status', 'delete_time'])
                ->create();
        }
    }

    public function shop_goods_params_template(): void
    {
        if (!$this->hasTable('shop_goods_params_template')) {
            $table = $this->table('shop_goods_params_template', [
                'id'          => false,
                'comment'     => '商品参数模板表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '模板名称', 'null' => false, 'default' => ''])
                ->addColumn('value', 'text', ['comment' => '参数信息'])
                ->addColumn('status', 'integer', ['comment' => '状态:0=禁用,1=启用', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['status'])
                ->create();
        }
    }

    public function shop_goods_service(): void
    {
        if (!$this->hasTable('shop_goods_service')) {
            $table = $this->table('shop_goods_service', [
                'id'          => false,
                'comment'     => '商品服务管理表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '服务名称', 'limit' => 50, 'null' => false, 'default' => ''])
                ->addColumn('content', 'string', ['comment' => '服务内容', 'null' => false, 'default' => ''])
                ->addColumn('status', 'integer', ['comment' => '状态:0=禁用,1=启用', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['status', 'delete_time'])
                ->create();
        }
    }

    public function shop_goods_sku(): void
    {
        if (!$this->hasTable('shop_goods_sku')) {
            $table = $this->table('shop_goods_sku', [
                'id'          => false,
                'comment'     => '商品sku表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('goods_id', 'integer', ['comment' => '商品ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('spec', 'string', ['comment' => '规格信息', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('image', 'string', ['comment' => '规格图片', 'null' => false, 'default' => ''])
                ->addColumn('price', 'decimal', ['comment' => '售价', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('origin_price', 'decimal', ['comment' => '划线价', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('stock', 'integer', ['comment' => '库存', 'null' => false, 'signed' => false, 'default' => '0'])
                ->addColumn('weight', 'decimal', ['comment' => '重量', 'precision' => 10, 'scale' => 3, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('volume', 'decimal', ['comment' => '体积', 'precision' => 10, 'scale' => 3, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('sku_code', 'string', ['comment' => 'SKU编码', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('sales', 'integer', ['comment' => '销量', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('stock_alert', 'integer', ['comment' => '库存预警值', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['goods_id', 'delete_time'], ['name' => 'idx_goods'])
                ->create();
        }
    }

    public function shop_goods_spec_template(): void
    {
        if (!$this->hasTable('shop_goods_spec_template')) {
            $table = $this->table('shop_goods_spec_template', [
                'id'          => false,
                'comment'     => '商品规格模板',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '模板名称', 'null' => false, 'default' => ''])
                ->addColumn('value', 'text', ['comment' => '模板参数'])
                ->addColumn('status', 'integer', ['comment' => '状态:0=禁用,1=启用', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['status'])
                ->create();
        }
    }

    public function shop_order(): void
    {
        if (!$this->hasTable('shop_order')) {
            $table = $this->table('shop_order', [
                'id'          => false,
                'comment'     => '订单表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('type', 'integer', ['comment' => '订单类型:1=普通订单', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('order_no', 'string', ['comment' => '订单号', 'limit' => 32, 'null' => false, 'default' => ''])
                ->addColumn('out_trade_no', 'string', ['comment' => '支付订单号', 'limit' => 32, 'null' => false, 'default' => ''])
                ->addColumn('user_id', 'integer', ['comment' => '用户id', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('status', 'integer', ['comment' => '订单状态:1=待付款,2=待发货,3=待收货,4=待评价,5=已完成,6=已取消,7=申请取消', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('pay_status', 'integer', ['comment' => '支付状态 1:待支付 2:已支付 3:已退款 4:部分退款', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('total_num', 'integer', ['comment' => '订单商品总数量', 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('pay_way', 'string', ['comment' => '支付方式', 'limit' => 20, 'null' => false, 'default' => ''])
                ->addColumn('total_price', 'decimal', ['comment' => '订单总金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('pay_price', 'decimal', ['comment' => '实际支付金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('freight', 'decimal', ['comment' => '运费', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('total_discount', 'decimal', ['comment' => '订单总优惠金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('discount_data', 'json', ['comment' => '订单享受优惠数据'])
                ->addColumn('discount_detail', 'json', ['comment' => '订单享受优惠详情'])
                ->addColumn('delivery_status', 'integer', ['comment' => '发货状态:1=未发货,2=已发货,3=部分发货', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('delivery_mode', 'integer', ['comment' => '发货模式:0=未发货,1=统一发货,2=分拆发货', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '0'])
                ->addColumn('cancel_reason', 'string', ['comment' => '取消理由', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('cancel_remark', 'string', ['comment' => '后台审核取消订单说明', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('source', 'string', ['comment' => '订单平台来源', 'limit' => 20, 'null' => false, 'default' => ''])
                ->addColumn('refund_status', 'integer', ['comment' => '退款状态 1:未退款 2:审批中 3:已退款', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('refund_amount', 'decimal', ['comment' => '已退款金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('refund_num', 'integer', ['comment' => '已退款数量', 'null' => false, 'default' => '0'])
                ->addColumn('remark', 'string', ['comment' => '用户备注', 'limit' => 1024, 'null' => false, 'default' => '0'])
                ->addColumn('user_del', 'integer', ['comment' => '是否被用户删除:0=否,1=是', 'signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('final_pay_time', 'biginteger', ['comment' => '最后支付时间(超时取消)', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('pay_time', 'biginteger', ['comment' => '支付时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delivery_time', 'biginteger', ['comment' => '发货时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('receive_time', 'biginteger', ['comment' => '收货时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('evaluate_time', 'biginteger', ['comment' => '评价时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('cancel_time', 'biginteger', ['comment' => '取消时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_no'], ['type' => 'UNIQUE'])
                ->addIndex(['out_trade_no'], ['type' => 'UNIQUE'])
                ->addIndex(['status', 'delete_time'], ['name' => 'soft_del'])
                ->addIndex(['create_time', 'total_price', 'delete_time'], ['name' => 'order_statistics'])
                ->addIndex(['pay_price', 'user_id', 'delete_time'], ['name' => 'user_order_statistics'])
                ->create();
        }
    }

    public function shop_order_detail(): void
    {
        if (!$this->hasTable('shop_order_detail')) {
            $table = $this->table('shop_order_detail', [
                'id'          => false,
                'comment'     => '订单详情表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('order_id', 'integer', ['comment' => '订单id', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('goods_id', 'integer', ['comment' => '商品id', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('goods_name', 'string', ['comment' => '商品名称', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('sku_id', 'integer', ['comment' => '商品sku_id', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('price', 'decimal', ['comment' => '单价', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('num', 'integer', ['comment' => '数量', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('total_price', 'decimal', ['comment' => '总价', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('pay_price', 'decimal', ['comment' => '实际支付单价', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('image', 'string', ['comment' => '商品图片', 'null' => false, 'default' => ''])
                ->addColumn('spec', 'string', ['comment' => '商品规格', 'null' => false, 'default' => ''])
                ->addColumn('discount_amount', 'decimal', ['comment' => '均摊的优惠金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('discount_data', 'json', ['comment' => '均摊的优惠信息'])
                ->addColumn('delivery_num', 'integer', ['comment' => '已发货数量', 'null' => false, 'default' => '0'])
                ->addColumn('delivery_time', 'biginteger', ['comment' => '发货时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('evaluate_time', 'biginteger', ['comment' => '评价时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['goods_id', 'total_price'], ['name' => 'sale_statistics'])
                ->create();
        }
    }

    public function shop_order_address(): void
    {
        if (!$this->hasTable('shop_order_address')) {
            $table = $this->table('shop_order_address', [
                'id'          => false,
                'comment'     => '用户订单收货记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('order_id', 'integer', ['comment' => '订单id', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('user_id', 'integer', ['comment' => '用户id', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('name', 'string', ['comment' => '收货人', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('phone', 'string', ['comment' => '联系方式', 'limit' => 20, 'null' => false, 'default' => ''])
                ->addColumn('province', 'string', ['comment' => '省份编码', 'limit' => 15, 'null' => false, 'default' => ''])
                ->addColumn('city', 'string', ['comment' => '城市编码', 'limit' => 15, 'null' => false, 'default' => ''])
                ->addColumn('county', 'string', ['comment' => '县区编码', 'limit' => 15, 'null' => false, 'default' => ''])
                ->addColumn('address', 'string', ['comment' => '详细地址', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('full_address', 'string', ['comment' => '完整收货地址', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('zipcode', 'string', ['comment' => '邮编', 'limit' => 20, 'null' => false, 'default' => ''])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_id'])
                ->addIndex(['user_id'])
                ->create();
        }
    }

    public function shop_order_delivery(): void
    {
        if (!$this->hasTable('shop_order_delivery')) {
            $table = $this->table('shop_order_delivery', [
                'id'          => false,
                'comment'     => '订单发货记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('order_id', 'integer', ['comment' => '订单ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('type', 'integer', ['comment' => '发货类型:1=快递配送,2=无需物流', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('delivery_company_id', 'string', ['comment' => '物流公司ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delivery_no', 'string', ['comment' => '物流单号', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_id'])
                ->create();
        }
    }

    public function shop_order_delivery_detail(): void
    {
        if (!$this->hasTable('shop_order_delivery_detail')) {
            $table = $this->table('shop_order_delivery_detail', [
                'id'          => false,
                'comment'     => '订单发货记录详情表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('delivery_id', 'integer', ['comment' => '发货单ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('order_id', 'integer', ['comment' => '订单ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('order_detail_id', 'integer', ['comment' => '订单详情ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('goods_id', 'integer', ['comment' => '商品ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delivery_num', 'integer', ['comment' => '发货数量', 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_id'])
                ->addIndex(['order_detail_id'])
                ->create();
        }
    }

    public function shop_order_evaluate(): void
    {
        if (!$this->hasTable('shop_order_evaluate')) {
            $table = $this->table('shop_order_evaluate', [
                'id'          => false,
                'comment'     => '订单评价记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('order_id', 'integer', ['comment' => '订单ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('order_detail_id', 'integer', ['comment' => '订单详情ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('goods_id', 'integer', ['comment' => '关联的商品ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('goods_name', 'string', ['comment' => '商品名称', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('goods_spec', 'string', ['comment' => '商品规格', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('score', 'integer', ['comment' => '评价分数', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('status', 'integer', ['comment' => '显示状态:0=隐藏,1=显示', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('content', 'string', ['comment' => '评价内容', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('images', 'string', ['comment' => '评价图片', 'limit' => 2048, 'null' => false, 'default' => ''])
                ->addColumn('user_id', 'integer', ['comment' => '评价人id', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('user_name', 'string', ['comment' => '评价人名称', 'null' => false, 'default' => ''])
                ->addColumn('user_avatar', 'string', ['comment' => '评价人头像', 'null' => false, 'default' => ''])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '修改时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_id'])
                ->addIndex(['goods_id'])
                ->addIndex(['user_id'])
                ->addIndex(['score'])
                ->create();
        }
    }

    public function shop_order_export(): void
    {
        if (!$this->hasTable('shop_order_export')) {
            $table = $this->table('shop_order_export', [
                'id'          => false,
                'comment'     => '订单导出记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('admin_id', 'integer', ['comment' => '导出人ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('name', 'string', ['comment' => '任务名称', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('export_fields', 'text', ['comment' => '导出字段'])
                ->addColumn('query_params', 'text', ['comment' => '查询参数'])
                ->addColumn('max_row_num', 'integer', ['comment' => '单个表格最大行数', 'null' => false, 'default' => '10000'])
                ->addColumn('status', 'integer', ['comment' => '导出状态:0=待导出,1=导出中,2=已成功,3=已失败', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('export_file_path', 'string', ['comment' => '导出文件路径', 'null' => false, 'default' => ''])
                ->addColumn('error_info', 'string', ['comment' => '导出错误记录', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('export_finish_time', 'biginteger', ['comment' => '导出完成时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('last_export_time', 'biginteger', ['comment' => '上次导出时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->create();
        }
    }

    public function shop_order_crontab(): void
    {
        if (!$this->hasTable('shop_order_crontab')) {
            $table = $this->table('shop_order_crontab', [
                'id'          => false,
                'comment'     => '订单定时任务表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
                ->addColumn('order_id', 'integer', ['comment' => '订单ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('action', 'string', ['comment' => '操作类型', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('time', 'integer', ['comment' => '执行时间', 'signed' => false, 'null' => false, 'default' => 0])
                ->addColumn('data', 'text', ['comment' => '执行数据'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_id'])
                ->addIndex(['time', 'action'], ['name' => 'action_time'])
                ->create();
        }
    }

    public function shop_order_refund(): void
    {
        if (!$this->hasTable('shop_order_refund')) {
            $table = $this->table('shop_order_refund', [
                'id'          => false,
                'comment'     => '订单售后记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('order_id', 'integer', ['comment' => '订单ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('order_detail_id', 'integer', ['comment' => '订单详情ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('user_id', 'integer', ['comment' => '用户ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('refund_type', 'integer', ['comment' => '售后类型:1退货退款,2=换货', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('refund_num', 'integer', ['comment' => '退款数量', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('remark', 'string', ['comment' => '申请说明', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('remark_images', 'string', ['comment' => '申请凭证', 'limit' => 1024, 'null' => false, 'default' => ''])
                ->addColumn('audit_status', 'integer', ['comment' => '商家审核状态:1=待审核,2=同意,3=拒绝', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('refuse_reason', 'string', ['comment' => '拒绝原因', 'null' => false, 'default' => ''])
                ->addColumn('apply_money', 'decimal', ['comment' => '申请金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('refund_money', 'decimal', ['comment' => '退款金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('refund_freight', 'decimal', ['comment' => '退款运费', 'precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0'])
                ->addColumn('user_ship_status', 'integer', ['comment' => '用户发货状态:0=未发货,1=已发货', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('user_ship_time', 'biginteger', ['comment' => '用户发货时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('receive_status', 'integer', ['comment' => '商家收货状态:0=未收货,1=已收货', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('receive_time', 'biginteger', ['comment' => '商家收货时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('status', 'integer', ['comment' => '售后单状态:1=进行中,2=已完成,3=已取消', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('refund_address', 'json', ['comment' => '商家售后地址'])
                ->addColumn('user_ship_delivery', 'json', ['comment' => '用户发货物流信息'])
                ->addColumn('exchange_delivery', 'json', ['comment' => '商家换货物流信息'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_id'])
                ->create();
        }
    }

    public function shop_order_status_log(): void
    {
        if (!$this->hasTable('shop_order_status_log')) {
            $table = $this->table('shop_order_status_log', [
                'id'          => false,
                'comment'     => '订单状态纪录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('order_id', 'integer', ['comment' => '订单ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('original_status', 'integer', ['comment' => '原始状态', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('new_status', 'integer', ['comment' => '当前最新状态', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('msg', 'string', ['comment' => '当前最新状态', 'null' => false, 'default' => ''])
                ->addColumn('operator_id', 'integer', ['comment' => '操作人ID', 'null' => false, 'default' => '0'])
                ->addColumn('is_admin', 'integer', ['comment' => '是否后台操作:0=否,1=是', 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_id'])
                ->create();
        }
    }

    public function shop_payment_trade(): void
    {
        if (!$this->hasTable('shop_payment_trade')) {
            $table = $this->table('shop_payment_trade', [
                'id'          => false,
                'comment'     => '第三方支付交易记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('out_trade_no', 'string', ['comment' => '交易支付订单号', 'limit' => 50, 'null' => false, 'default' => ''])
                ->addColumn('order_type', 'string', ['comment' => '订单类型:1=商城订单,2=充值订单', 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('order_id', 'integer', ['comment' => '订单类型对应的订单ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('user_id', 'integer', ['comment' => '下单用户ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('pay_way', 'string', ['comment' => '支付方式', 'limit' => 20, 'null' => false, 'default' => ''])
                ->addColumn('trade_no', 'string', ['comment' => '第三方交易流水号', 'limit' => 50, 'null' => false, 'default' => ''])
                ->addColumn('source', 'string', ['comment' => '订单来源/平台', 'limit' => 20, 'null' => false, 'default' => ''])
                ->addColumn('pay_params', 'json', ['comment' => '交易参数'])
                ->addColumn('pay_result', 'json', ['comment' => '交易结果'])
                ->addColumn('refund_result', 'json', ['comment' => '交易退款结果'])
                ->addColumn('trade_state', 'integer', ['comment' => '交易状状态:1=未支付,2=支付成功,3=退款', 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['out_trade_no'], ['type' => 'UNIQUE'])
                ->addIndex(['order_type'])
                ->addIndex(['order_id', 'out_trade_no'], ['name' => 'idx_order_payment'])
                ->addIndex(['trade_state'])
                ->create();
        }
    }

    public function shop_recharge_plan(): void
    {
        if (!$this->hasTable('shop_recharge_plan')) {
            $table = $this->table('shop_recharge_plan', [
                'id'          => false,
                'comment'     => '余额充值套餐表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '套餐名称', 'null' => false, 'default' => ''])
                ->addColumn('money', 'decimal', ['comment' => '充值金额', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('gift_money', 'decimal', ['comment' => '赠送金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'signed' => false, 'default' => '0'])
                ->addColumn('weigh', 'decimal', ['comment' => '排序权重', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->create();
        }
    }

    public function shop_recharge_order(): void
    {
        if (!$this->hasTable('shop_recharge_order')) {
            $table = $this->table('shop_recharge_order', [
                'id'          => false,
                'comment'     => '会员充值订单记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('order_no', 'string', ['comment' => '订单号', 'limit' => 50, 'null' => false, 'default' => ''])
                ->addColumn('out_trade_no', 'string', ['comment' => '支付订单号', 'limit' => 50, 'null' => false, 'default' => ''])
                ->addColumn('user_id', 'integer', ['comment' => '用户ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('recharge_type', 'integer', ['comment' => '充值方式:1=套餐,2=自定义金额', 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('money', 'decimal', ['comment' => '充值金额', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('gift_money', 'decimal', ['comment' => '赠送金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'signed' => false, 'default' => '0'])
                ->addColumn('pay_price', 'decimal', ['comment' => '实际支付金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'signed' => false, 'default' => '0'])
                ->addColumn('actual_money', 'decimal', ['comment' => '实际到账金额', 'precision' => 10, 'scale' => 2, 'null' => false, 'signed' => false, 'default' => '0'])
                ->addColumn('pay_way', 'string', ['comment' => '支付方式', 'null' => false, 'default' => ''])
                ->addColumn('pay_status', 'integer', ['comment' => '支付状态:1=未支付,2=已支付,3=已退款', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('pay_time', 'biginteger', ['comment' => '付款时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('source', 'string', ['comment' => '订单来源', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => ''])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'limit' => 20, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['order_no'], ['type' => 'UNIQUE'])
                ->addIndex(['out_trade_no'], ['type' => 'UNIQUE'])
                ->addIndex(['delete_time'])
                ->addIndex(['user_id', 'delete_time'])
                ->create();
        }
    }

    public function shop_setting(): void
    {
        if (!$this->hasTable('shop_setting')) {
            $table = $this->table('shop_setting', [
                'id'          => false,
                'comment'     => '系统设置表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'identity' => true, 'signed' => false, 'null' => false])
                ->addColumn('name', 'string', ['comment' => '变量名', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('group', 'string', ['comment' => '变量分组', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('title', 'string', ['comment' => '变量标题', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('tip', 'string', ['comment' => '变量描述', 'limit' => 100, 'null' => false, 'default' => ''])
                ->addColumn('type', 'string', ['comment' => '变量输入组件类型', 'limit' => 30, 'null' => false, 'default' => ''])
                ->addColumn('value', 'text', ['comment' => '变量值', 'limit' => MysqlAdapter::TEXT_LONG])
                ->addColumn('content', 'text', ['comment' => '字典数据', 'limit' => MysqlAdapter::TEXT_LONG])
                ->addColumn('rule', 'string', ['comment' => '变量输入组件类型', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('extend', 'string', ['comment' => '扩展属性', 'limit' => 255, 'null' => false, 'default' => ''])
                ->addColumn('weigh', 'integer', ['comment' => '排序权重', 'null' => false, 'default' => '0'])
                ->addColumn('allow_del', 'integer', ['comment' => '是否允许删除:0=否,1=是', 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '0'])
                ->addIndex(['name'], ['type' => 'UNIQUE'])
                ->addIndex(['group'])
                ->create();
        }
    }

    public function shop_user(): void
    {
        if (!$this->hasTable('shop_user')) {
            $table = $this->table('shop_user', [
                'id'          => false,
                'comment'     => '用户表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
                ->addColumn('openid', 'string', ['comment' => '微信openid', 'limit' => 32, 'null' => false, 'default' => ''])
                ->addColumn('username', 'string', ['limit' => 32, 'default' => '', 'comment' => '用户名', 'null' => false])
                ->addColumn('nickname', 'string', ['limit' => 50, 'default' => '', 'comment' => '昵称', 'null' => false])
                ->addColumn('email', 'string', ['limit' => 50, 'default' => '', 'comment' => '邮箱', 'null' => false])
                ->addColumn('mobile', 'string', ['limit' => 11, 'default' => '', 'comment' => '手机', 'null' => false])
                ->addColumn('avatar', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像', 'null' => false])
                ->addColumn('gender', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '性别:0=保密,1=男,2=女', 'null' => false])
                ->addColumn('birthday', 'date', ['comment' => '生日'])
                ->addColumn('money', 'integer', ['comment' => '余额', 'default' => 0, 'null' => false])
                ->addColumn('score', 'integer', ['comment' => '积分', 'default' => 0, 'null' => false])
                ->addColumn('last_login_time', 'biginteger', ['limit' => 20, 'signed' => false, 'null' => false, 'default' => 0, 'comment' => '上次登录时间'])
                ->addColumn('last_login_ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP', 'null' => false])
                ->addColumn('login_failure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数', 'null' => false])
                ->addColumn('motto', 'string', ['limit' => 255, 'default' => '', 'comment' => '签名', 'null' => false])
                ->addColumn('password', 'string', ['limit' => 32, 'default' => '', 'comment' => '密码', 'null' => false])
                ->addColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐', 'null' => false])
                ->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'default' => '1', 'comment' => '状态', 'null' => false])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['username'], ['unique' => true])
                ->addIndex(['mobile'], ['unique' => true])
                ->addIndex(['nickname'])
                ->create();
        }
    }

    public function shop_user_address(): void
    {
        if (!$this->hasTable('shop_user_address')) {
            $table = $this->table('shop_user_address', [
                'id'          => false,
                'comment'     => '用户地址表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
                ->addColumn('user_id', 'integer', ['comment' => '用户id', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('name', 'string', ['comment' => '收货人姓名', 'limit' => 32, 'null' => false, 'default' => ''])
                ->addColumn('phone', 'string', ['comment' => '收货人联系方式', 'limit' => 20, 'null' => false, 'default' => ''])
                ->addColumn('province', 'string', ['comment' => '省编码', 'limit' => 10, 'null' => false, 'default' => ''])
                ->addColumn('city', 'string', ['comment' => '市编码', 'limit' => 10, 'null' => false, 'default' => ''])
                ->addColumn('county', 'string', ['comment' => '区编码', 'limit' => 10, 'null' => false, 'default' => ''])
                ->addColumn('full_location', 'string', ['comment' => '省市区名称', 'null' => false, 'default' => ''])
                ->addColumn('address', 'string', ['comment' => '收货人详细地址', 'null' => false, 'default' => ''])
                ->addColumn('zipcode', 'string', ['comment' => '邮编', 'limit' => 10, 'null' => false, 'default' => ''])
                ->addColumn('is_default', 'integer', ['comment' => '是否默认:0=否,1=是', 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['user_id'])
                ->addIndex(['province', 'city', 'county'], ['name' => 'idx_area'])
                ->addIndex(['is_default'])
                ->create();
        }
    }

    public function shop_user_cart(): void
    {
        if (!$this->hasTable('shop_user_cart')) {
            $table = $this->table('shop_user_cart', [
                'id'          => false,
                'comment'     => '购物车表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
                ->addColumn('user_id', 'integer', ['comment' => '用户ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('goods_id', 'integer', ['comment' => '商品ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('sku_id', 'integer', ['comment' => '商品skuId', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('num', 'integer', ['comment' => '数量', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('old_price', 'decimal', ['comment' => '加入时的价格', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('selected', 'integer', ['comment' => '是否被选中:0=否,1=是', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['user_id'])
                ->create();
        }
    }

    public function shop_user_coupon(): void
    {
        if (!$this->hasTable('shop_user_coupon')) {
            $table = $this->table('shop_user_coupon', [
                'id'          => false,
                'comment'     => '用户优惠券记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
                ->addColumn('user_id', 'integer', ['comment' => '用户ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('coupon_id', 'integer', ['comment' => '优惠券ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('coupon_center_id', 'integer', ['comment' => '领券中心券ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('start_time', 'biginteger', ['comment' => '开始时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('end_time', 'biginteger', ['comment' => '结束时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('status', 'integer', ['comment' => '优惠券状态:1=待使用,2=已使用,3=已过期', 'limit' => MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '领券时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['user_id'])
                ->addIndex(['coupon_id'])
                ->addIndex(['user_id', 'coupon_id'], ['name' => 'idx_user_coupon'])
                ->addIndex(['start_time', 'end_time'], ['name' => 'idx_effective_time'])
                ->addIndex(['status', 'delete_time'], ['name' => 'idx_coupon_status'])
                ->create();
        }
    }

    public function shop_user_favorite(): void
    {
        if (!$this->hasTable('shop_user_favorite')) {
            $table = $this->table('shop_user_favorite', [
                'id'          => false,
                'comment'     => '用户收藏记录表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
                ->addColumn('user_id', 'integer', ['comment' => '用户ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('goods_id', 'integer', ['comment' => '商品ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('old_price', 'decimal', ['comment' => '收藏时的价格', 'precision' => 10, 'scale' => 2, 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('update_time', 'biginteger', ['comment' => '更新时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('delete_time', 'biginteger', ['comment' => '删除时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex(['user_id', 'goods_id'], ['name' => 'idx_user_favorite'])
                ->addIndex(['delete_time'])
                ->create();
        }
    }

    public function shop_user_money_log(): void
    {
        if (!$this->hasTable('shop_user_money_log')) {
            $table = $this->table('shop_user_money_log', [
                'id'          => false,
                'comment'     => '用户余额流水表',
                'row_format'  => 'DYNAMIC',
                'primary_key' => 'id',
                'collation'   => 'utf8mb4_unicode_ci',
            ]);
            $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false])
                ->addColumn('user_id', 'integer', ['comment' => '用户ID', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addColumn('money', 'integer', ['comment' => '变更余额(单位：分)', 'null' => false, 'default' => '0'])
                ->addColumn('before', 'integer', ['comment' => '变更前余额(单位：分)', 'null' => false, 'default' => '0'])
                ->addColumn('after', 'integer', ['comment' => '变更后余额(单位：分)', 'null' => false, 'default' => '0'])
                ->addColumn('memo', 'string', ['comment' => '变更备注', 'null' => false, 'default' => ''])
                ->addColumn('type', 'integer', ['comment' => '变动类型', 'limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '1'])
                ->addColumn('create_time', 'biginteger', ['comment' => '创建时间', 'signed' => false, 'null' => false, 'default' => '0'])
                ->addIndex('user_id')
                ->addIndex(['user_id', 'type'], ['name' => 'idx_user_money'])
                ->create();
        }
    }
}
